<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page trimDirectiveWhitespaces="true" %>
<%@include file="/admin/include/includeAdminTaglibs.jsp" %>
<!Doctype html>
<t:base type="jquery,easyui1.5,dateformat"></t:base>
<t:datagrid name="infoGrid" actionUrl="/admin/admin/list?isAdmin=1" fit="true" fitColumns="true" idField="id" queryMode="group" pageSize="20" title="管理员列表">
    <t:dgCol title="编号" field="userId" hidden="false"></t:dgCol>
    <t:dgCol title="用户名" sortable="false" field="userName"></t:dgCol>
    <t:dgCol title="真实姓名" sortable="false" field="realName"></t:dgCol>
    <t:dgCol title="创建时间" sortable="false" field="createDate"></t:dgCol>
    <t:dgCol title="修改时间" sortable="false" field="updateDate"></t:dgCol>
    <t:dgToolBar title="添加管理员" icon="icon-add" funname="openDialog" url="/admin/admin/add" width="28%"></t:dgToolBar>
    <t:dgToolBar title="修改管理员" icon="icon-edit" funname="editService" url="/admin/admin/update" width="26%" idFiledName="userId"></t:dgToolBar>
    <t:dgToolBar title="修改密码" icon="icon-lock" funname="updatePwd" url="/admin/admin/updatePassword" idFiledName="userId" width="26%"></t:dgToolBar>
</t:datagrid>
<script>
    var buttons = [{
        text: '确认',
        iconCls: 'icon-ok',
        handler: function () {
            submitForm()
        }
    }, {
        text: '关闭',
        iconCls: 'icon-cancel',
        handler: function () {
            $dialog.window("close")
        }
    }];
    function openDialog(title, url, gridId, width, height) {
        $dialog = $("<div></div>").dialog({
            title: title,
            href: url,
            modal: true,
            width:300,
            height:200,
            buttons: buttons,
            onClose: function () {
                $(this).window("window").nextAll('.window-shadow,.window-mask').remove()
                $(this).window("window").remove()
            }
        })
    }
    function editService(title, url, gridId, width, height, idFiledName) {
        var rowsData = $("#" + gridId).datagrid('getSelected');
        if (rowsData == null) {
            top.tip('请选择要修改的管理员');
            return;
        }
        if(rowsData[idFiledName]==1){
            top.tip('超级管理员不允许修改');
            return
        }
        url += '/' + rowsData[idFiledName]
        openDialog("修改管理员",url)
    }
    function updatePwd(title, url, gridId, width, height, idFiledName) {
        var rowsData = $("#" + gridId).datagrid('getSelected');
        if (rowsData==null) {
            top.tip('请选择修改密码的管理员');
            return;
        }
        url += '?userId=' + rowsData[idFiledName]
        openDialog(title, url, gridId, width, height)
    }
</script>